class_name Saw
extends Area2D
export var rotation_speed:float = -2*PI
export var dir_h:bool = true
export var dis:int = 100
export var speed:int = 100
export var damage:int = 10
var dir:int = 1
var init_x:int = 0
var init_y:int = 0

# Called when the node enters the scene tree for the first time.
func _ready():
	init_x = position.x #设定了初始的x
	init_y = position.y #设定了初始的y


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	rotation += rotation_speed*delta*-dir
	if dir_h:
		position.x+= speed*delta*dir
		if position.x> init_x+dis:
			dir = -1
			$Sprite.flip_h = false
		elif position.x<init_x:
			dir = 1
			$Sprite.flip_h = true
	else:
		position.y+=speed*delta*dir
		if position.y>init_y+dis:
			dir = -1
			$Sprite.flip_v = false
		elif position.y<init_y:
			dir = 1
			$Sprite.flip_v = true
	pass
